package com.telit.firecommand.feign.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.telit.common.enums.ResultCode;
import com.telit.common.vo.user.Result;
import com.telit.firecommand.dto.FeignTaskNumDto;
import com.telit.firecommand.dto.PatPersonPatrolInfoPageDto;
import com.telit.firecommand.dto.ReleaseTaskDto;
import com.telit.firecommand.dto.TsTaskInfoPageDto;
import com.telit.firecommand.feign.PatrolFeignClient;
import com.telit.firecommand.vo.FeignTaskNumVo;
import com.telit.firecommand.vo.PatPersonPatrolInfoVo;
import com.telit.firecommand.vo.TaskInfoListVo;
import com.telit.firecommand.vo.TaskInfoVo;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;


/**
 * Create by Chencf 2022/09/17
 */
@Component
@Slf4j
public class PatrolFeignClientFallBack implements PatrolFeignClient {

    @Setter
    private Throwable cause;

    @Override
    public Result feignReleaseTask(@RequestBody ReleaseTaskDto releaseTaskDto) {
        log.error("feign 调用护林员上报:{}", cause);
        return new Result<>(ResultCode.SERVER_FEIGN_ERROR.getCode(), false, "护林员上报远程调用失败");
    }

    @Override
    public Result<IPage<TaskInfoListVo>> getTaskListByPerson(TsTaskInfoPageDto pageDto) {
        return new Result<>(ResultCode.SERVER_FEIGN_ERROR.getCode(), false,
                "根据林长、护林员ID、任务类型，二级任务类型、任务状态、任务开始、结束时间分页获取任务列表失败）");
    }

    @Override
    public Result<TaskInfoVo> findTaskInfoDetail(@RequestParam("taskId") Long taskId,
                                                 @RequestParam("userId") Long userId) {
        return new Result<>(ResultCode.SERVER_FEIGN_ERROR.getCode(), false, "根据任务ID获取任务详情（包含任务信息、反馈信息、巡护记录失败）");
    }

    @Override
    public Result<List<FeignTaskNumVo>> countForTask(FeignTaskNumDto feignTaskNumDto) {
        return new Result<>(ResultCode.SERVER_FEIGN_ERROR.getCode(), false, "调用统计接口失败");
    }

    @Override
    public Result fireTaskList(String fireId, Integer current, Integer size) {
        return new Result<>(ResultCode.SERVER_FEIGN_ERROR.getCode(), false, "根据火情id查询火情巡护任务接口异常");
    }

    @Override
    public Result findHlyListForFireId(String fireId, Integer current, Integer size) {
        return new Result<>(ResultCode.SERVER_FEIGN_ERROR.getCode(), false, "根据火情id获取执行护林员列表异常");
    }

    @Override
    public Result findTaskListForFireId(String fireId, Integer current, Integer size, String personId) {
        return new Result<>(ResultCode.SERVER_FEIGN_ERROR.getCode(), false, "根据火情id + 护林员id，获取执行任务列表");
    }

    @Override
    public Result<IPage<PatPersonPatrolInfoVo>> findPersonPatrolInfoList(
            PatPersonPatrolInfoPageDto patPersonPatrolInfoPageDto) {
        return new Result<>(ResultCode.SERVER_FEIGN_ERROR.getCode(), false, "依据查询条件分页查询人员巡护记录列表失败");
    }

    @Override
    public Result<TaskInfoVo> feignReleaseTask(Long id) {
        return new Result<>(ResultCode.SERVER_FEIGN_ERROR.getCode(), false, "依据巡护、巡林记录ID,获取详情失败");
    }

}
